บันทึกของบี

บันทึกการเดินทาง บนเส้นทางเดินแห่งชีวิต ของคนธรรมดาคนหนึ่ง

Ch7 Enums and Pattern Matching

2026-07-12 ใน The rust programming language 3rd edition(online document)

All enums variants are like the Self{...} implementation of struct. So the usage is Enum_name::variant not .method()

  • However, the .method() for enum is still usable with impl
enum Message{
    Move(i32,i32),
}
impl Test{
    fn method(&self) -> bool{
        ...
    }
}